package com.moralesce.gt.model;

/**
 * The nine different types of 5-card poker hand.
 * 
 * <p>
 * A 5-card poker hand will be one of the following hand types:<br/>
 * 
 * 1. High Card<br/>
 * 2. One Pair<br/>
 * 3. Two Pair<br/>
 * 4. Three of a Kind<br/>
 * 5. Straight<br/>
 * 6. Flush<br/>
 * 7. Full House<br/>
 * 8. Four of a Kind<br/>
 * 9. Straight Flush<br/>
 * </p>
 * 
 * @author Brandon Grenier
 */
public enum HandType {

	HIGH_CARD("HC", "High Card", 1), ONE_PAIR("1P", "One Pair", 2), TWO_PAIR("2P", "Two Pair", 3), THREE_OF_A_KIND("3K", "Three of a Kind", 4), STRAIGHT("S", "Straight", 5), FLUSH("F", "Flush", 6), FULL_HOUSE("FH", "Full House", 7), FOUR_OF_A_KIND("4K", "Four of a Kind", 8), STRAIGHT_FLUSH("SF", "Straight Flush", 9);

	private final String value;
	private final String label;
	private final Integer order;

	private HandType(String value, String label, Integer order) {
		this.value = value;
		this.label = label;
		this.order = order;
	}

	/**
	 * Returns the hand type value.
	 * 
	 * The hand type value will be one of:<br/>
	 * HC, 1P, 2P, 3K, S, F, FH, 4K, SF
	 * 
	 * @return The hand type id.
	 */
	public String value() {
		return value;
	}

	/**
	 * Returns the hand type label.
	 * 
	 * @return The hand type label.
	 */
	public String label() {
		return label;
	}

	/**
	 * Returns the hand type order.
	 * 
	 * @return The hand type order.
	 */
	public Integer order() {
		return order;
	}

	/**
	 * Returns the hand type for the given value.
	 * 
	 * @param value The value.
	 * 
	 * @return The hand type for the given value.
	 * 
	 * @throws IllegalArgumentException if the specified value does not map to a
	 * hand type.
	 */
	public static HandType forValue(String value) {
		for (HandType type : HandType.values()) {
			if (type.value().equalsIgnoreCase(value)) {
				return type;
			}
		}
		throw new IllegalArgumentException(value + " is not a valid hand type");
	}

}
